// Teacher/src/main/java/org/cyzy/service/impl/CurriculumServiceImpl.java
package org.cyzy.service.impl;

import org.cyzy.entity.Course;
import org.cyzy.mapper.CourseMapper;
import org.cyzy.service.CurriculumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 课程表服务实现类
 */
@Service
public class CurriculumServiceImpl implements CurriculumService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public List<Course> getAllCoursesByClassId(Integer classId) {
        // 调用Mapper获取该班级的所有课程，若为null则返回空数组
        List<Course> courses = courseMapper.getAllCoursesByClassId(classId);
        return courses != null ? courses : new ArrayList<>(); // 关键修复：确保返回数组
    }
}